#!/bin/bash
#
# varnishd      start varnish service
#
# Author:       Ricardo Brito do Nascimento <ricardo[at]rbncurriculo.cjb.net>
#
# Date: 	24/5/2011
#
# chkconfig:    12345 97 03
#
# description:  Start varnish service.
#
# processname: varnishd


VARNISH_HOME=/opt/varnish-cache-2.1.5

_start(){
echo start
$VARNISH_HOME/etc/varnish/varnish-start
}

_stop(){
echo stop
$VARNISH_HOME/etc/varnish/varnish-stop
}

_status(){
echo status;
echo
echo -n "$0: " 
   [ -e $VARNISH_HOME/etc/varnish/varnish.pid ] && echo 'Serviço Ativo' || echo 'Serviço Inativo';
echo
}

_restart(){
echo restart
_stop
_start
}

_help(){
cat << fim

     $0 {start|stop|restart|status}

     start   = inicia o serviço
     stop    = para o serviço
     restart = reinicia o serviço
     status  = verifica o estado do serviço

     ex: $0 restart

fim
}

case $1 in
        start) _start;;
        stop) _stop;;
        status) _status;;
        restart) _restart;;
        -h|--help|?) _help;;
        *) echo -e "\nuse: $0 {start|stop|restart|status} \nou: \"$0 --help\" para mais informações\n" ;;
esac
